using NoteManger.Properties;
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace NoteManger
{
	public class FrmAlterPwd : TemplateForm
	{
		private IContainer components = null;
		private GroupBox groupBox;
		private TextBox tboxAgainPwd;
		private Label label4;
		private TextBox tboxNewPwd;
		private Label label3;
		private Button btnCancel;
		private Button btnAlterPwd;
		private GroupBox gboxsplit;
		private TextBox tboxOldPwd;
		private Label label2;
		private PictureBox pboxOldPwd;
		private PictureBox pboxCheckPwd;
		private Button btnHelp;
		private NoteRemote _NoteRemoteObject = null;
		private TLoginInfo _LoginInfo = new TLoginInfo();
		public NoteRemote NoteRemoteObject
		{
			set
			{
				this._NoteRemoteObject = value;
			}
		}
		public TLoginInfo LoginInfo
		{
			set
			{
				this._LoginInfo = value;
			}
		}
		protected override void Dispose(bool disposing)
		{
			if (disposing && this.components != null)
			{
				this.components.Dispose();
			}
			base.Dispose(disposing);
		}
		private void InitializeComponent()
		{
			this.groupBox = new GroupBox();
			this.pboxCheckPwd = new PictureBox();
			this.pboxOldPwd = new PictureBox();
			this.tboxAgainPwd = new TextBox();
			this.label4 = new Label();
			this.tboxNewPwd = new TextBox();
			this.label3 = new Label();
			this.btnCancel = new Button();
			this.btnAlterPwd = new Button();
			this.gboxsplit = new GroupBox();
			this.tboxOldPwd = new TextBox();
			this.label2 = new Label();
			this.btnHelp = new Button();
			this.groupBox.SuspendLayout();
			((ISupportInitialize)this.pboxCheckPwd).BeginInit();
			((ISupportInitialize)this.pboxOldPwd).BeginInit();
			base.SuspendLayout();
			this.groupBox.Controls.Add(this.btnHelp);
			this.groupBox.Controls.Add(this.pboxCheckPwd);
			this.groupBox.Controls.Add(this.pboxOldPwd);
			this.groupBox.Controls.Add(this.tboxAgainPwd);
			this.groupBox.Controls.Add(this.label4);
			this.groupBox.Controls.Add(this.tboxNewPwd);
			this.groupBox.Controls.Add(this.label3);
			this.groupBox.Controls.Add(this.btnCancel);
			this.groupBox.Controls.Add(this.btnAlterPwd);
			this.groupBox.Controls.Add(this.gboxsplit);
			this.groupBox.Controls.Add(this.tboxOldPwd);
			this.groupBox.Controls.Add(this.label2);
			this.groupBox.Font = new System.Drawing.Font("宋体", 12f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
			this.groupBox.ForeColor = System.Drawing.Color.White;
			this.groupBox.Location = new System.Drawing.Point(12, 18);
			this.groupBox.Name = "groupBox";
			this.groupBox.Size = new System.Drawing.Size(432, 236);
			this.groupBox.TabIndex = 18;
			this.groupBox.TabStop = false;
			this.groupBox.Text = "修改密码";
			this.pboxCheckPwd.Location = new System.Drawing.Point(18, 123);
			this.pboxCheckPwd.Name = "pboxCheckPwd";
			this.pboxCheckPwd.Size = new System.Drawing.Size(48, 48);
			this.pboxCheckPwd.SizeMode = PictureBoxSizeMode.StretchImage;
			this.pboxCheckPwd.TabIndex = 29;
			this.pboxCheckPwd.TabStop = false;
			this.pboxOldPwd.Location = new System.Drawing.Point(18, 31);
			this.pboxOldPwd.Name = "pboxOldPwd";
			this.pboxOldPwd.Size = new System.Drawing.Size(48, 48);
			this.pboxOldPwd.SizeMode = PictureBoxSizeMode.StretchImage;
			this.pboxOldPwd.TabIndex = 28;
			this.pboxOldPwd.TabStop = false;
			this.tboxAgainPwd.Font = new System.Drawing.Font("宋体", 10.5f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 134);
			this.tboxAgainPwd.Location = new System.Drawing.Point(165, 133);
			this.tboxAgainPwd.Name = "tboxAgainPwd";
			this.tboxAgainPwd.PasswordChar = 'Ж';
			this.tboxAgainPwd.Size = new System.Drawing.Size(237, 23);
			this.tboxAgainPwd.TabIndex = 2;
			this.tboxAgainPwd.KeyPress += new KeyPressEventHandler(this.tboxAgainPwd_KeyPress);
			this.label4.AutoSize = true;
			this.label4.Font = new System.Drawing.Font("宋体", 10.5f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
			this.label4.ForeColor = System.Drawing.Color.White;
			this.label4.Location = new System.Drawing.Point(70, 139);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(84, 14);
			this.label4.TabIndex = 25;
			this.label4.Text = "再输一次(&R)";
			this.tboxNewPwd.Font = new System.Drawing.Font("宋体", 10.5f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 134);
			this.tboxNewPwd.Location = new System.Drawing.Point(165, 88);
			this.tboxNewPwd.Name = "tboxNewPwd";
			this.tboxNewPwd.PasswordChar = 'Ж';
			this.tboxNewPwd.Size = new System.Drawing.Size(237, 23);
			this.tboxNewPwd.TabIndex = 1;
			this.tboxNewPwd.KeyPress += new KeyPressEventHandler(this.tboxNewPwd_KeyPress);
			this.label3.AutoSize = true;
			this.label3.Font = new System.Drawing.Font("宋体", 10.5f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
			this.label3.ForeColor = System.Drawing.Color.White;
			this.label3.Location = new System.Drawing.Point(70, 93);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(84, 14);
			this.label3.TabIndex = 23;
			this.label3.Text = "新 密 码(&N)";
			this.btnCancel.BackColor = System.Drawing.Color.FromArgb(192, 192, 255);
			this.btnCancel.Font = new System.Drawing.Font("宋体", 10.5f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
			this.btnCancel.ForeColor = System.Drawing.Color.FromArgb(51, 79, 103);
			this.btnCancel.Location = new System.Drawing.Point(327, 201);
			this.btnCancel.Name = "btnCancel";
			this.btnCancel.Size = new System.Drawing.Size(75, 26);
			this.btnCancel.TabIndex = 4;
			this.btnCancel.Text = "取消";
			this.btnCancel.UseVisualStyleBackColor = false;
			this.btnCancel.Click += new EventHandler(this.btnCancel_Click);
			this.btnAlterPwd.BackColor = System.Drawing.Color.FromArgb(192, 192, 255);
			this.btnAlterPwd.Font = new System.Drawing.Font("宋体", 10.5f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
			this.btnAlterPwd.ForeColor = System.Drawing.Color.FromArgb(51, 79, 103);
			this.btnAlterPwd.Location = new System.Drawing.Point(226, 201);
			this.btnAlterPwd.Name = "btnAlterPwd";
			this.btnAlterPwd.Size = new System.Drawing.Size(95, 26);
			this.btnAlterPwd.TabIndex = 3;
			this.btnAlterPwd.Text = "修改(&A)";
			this.btnAlterPwd.UseVisualStyleBackColor = false;
			this.btnAlterPwd.Click += new EventHandler(this.btnAlterPwd_Click);
			this.gboxsplit.Location = new System.Drawing.Point(7, 184);
			this.gboxsplit.Name = "gboxsplit";
			this.gboxsplit.Size = new System.Drawing.Size(419, 7);
			this.gboxsplit.TabIndex = 20;
			this.gboxsplit.TabStop = false;
			this.tboxOldPwd.Font = new System.Drawing.Font("宋体", 10.5f, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, 134);
			this.tboxOldPwd.Location = new System.Drawing.Point(165, 44);
			this.tboxOldPwd.Name = "tboxOldPwd";
			this.tboxOldPwd.PasswordChar = 'Ж';
			this.tboxOldPwd.Size = new System.Drawing.Size(237, 23);
			this.tboxOldPwd.TabIndex = 0;
			this.tboxOldPwd.KeyPress += new KeyPressEventHandler(this.tboxOldPwd_KeyPress);
			this.label2.AutoSize = true;
			this.label2.Font = new System.Drawing.Font("宋体", 10.5f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
			this.label2.ForeColor = System.Drawing.Color.White;
			this.label2.Location = new System.Drawing.Point(70, 47);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(84, 14);
			this.label2.TabIndex = 18;
			this.label2.Text = "旧 密 码(&O)";
			this.btnHelp.Image = Resources.information_2;
			this.btnHelp.Location = new System.Drawing.Point(18, 201);
			this.btnHelp.Name = "btnHelp";
			this.btnHelp.Size = new System.Drawing.Size(24, 24);
			this.btnHelp.TabIndex = 30;
			this.btnHelp.UseVisualStyleBackColor = true;
			this.btnHelp.Click += new EventHandler(this.btnHelp_Click);
			base.AutoScaleDimensions = new System.Drawing.SizeF(6f, 12f);
			base.AutoScaleMode = AutoScaleMode.Font;
			this.BackColor = System.Drawing.Color.FromArgb(51, 79, 103);
			base.ClientSize = new System.Drawing.Size(456, 266);
			base.Controls.Add(this.groupBox);
			base.FormBorderStyle = FormBorderStyle.None;
			base.MaximizeBox = false;
			base.MinimizeBox = false;
			base.Name = "FrmAlterPwd";
			base.ShowInTaskbar = false;
			base.StartPosition = FormStartPosition.CenterScreen;
			this.Text = "修改密码";
			this.groupBox.ResumeLayout(false);
			this.groupBox.PerformLayout();
			((ISupportInitialize)this.pboxCheckPwd).EndInit();
			((ISupportInitialize)this.pboxOldPwd).EndInit();
			base.ResumeLayout(false);
		}
		public FrmAlterPwd()
		{
			this.InitializeComponent();
			try
			{
				System.Drawing.Image image = System.Drawing.Image.FromFile(NoteRemote.GetNoteClientStartPath() + "\\png\\Key.png");
				this.pboxOldPwd.Image = image;
				image = System.Drawing.Image.FromFile(NoteRemote.GetNoteClientStartPath() + "\\png\\ReEnter.png");
				this.pboxCheckPwd.Image = image;
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
			}
		}
		private void btnAlterPwd_Click(object sender, EventArgs e)
		{
			string text = "";
			this.tboxOldPwd.Focus();
			if (this.tboxNewPwd.Text.Trim() == "")
			{
				if (MessageBox.Show("空密码是不被推荐的！要继续吗？", "修改密码", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk, MessageBoxDefaultButton.Button2) == DialogResult.No)
				{
					this.tboxNewPwd.Text = "";
					this.tboxAgainPwd.Text = "";
					if (this.tboxNewPwd.CanFocus)
					{
						this.tboxNewPwd.Focus();
					}
					return;
				}
			}
			try
			{
				if (!this._NoteRemoteObject.ConnectionTest())
				{
					MessageBox.Show("远程连接已断开，请重新连接后再试！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
					return;
				}
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message + "远程连接已断开，请重新连接后再试！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				return;
			}
			bool flag = false;
			try
			{
				flag = this._NoteRemoteObject.AlterUserPwd(this._LoginInfo.LoginID, this.tboxOldPwd.Text.Trim(), this.tboxNewPwd.Text.Trim(), this.tboxAgainPwd.Text.Trim(), ref text);
			}
			catch (Exception ex)
			{
				MessageBox.Show(ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
			}
			if (flag)
			{
				MessageBox.Show("密码修改成功！", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
				base.DialogResult = DialogResult.OK;
			}
			else
			{
				MessageBox.Show(text, "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
			}
		}
		private void btnCancel_Click(object sender, EventArgs e)
		{
			base.DialogResult = DialogResult.Cancel;
		}
		private void tboxOldPwd_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == '\r')
			{
				if (this.tboxNewPwd.CanFocus)
				{
					this.tboxNewPwd.Focus();
				}
				e.Handled = true;
			}
		}
		private void tboxNewPwd_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == '\r')
			{
				if (this.tboxAgainPwd.CanFocus)
				{
					this.tboxAgainPwd.Focus();
				}
				e.Handled = true;
			}
		}
		private void tboxAgainPwd_KeyPress(object sender, KeyPressEventArgs e)
		{
			if (e.KeyChar == '\r')
			{
				if (this.btnAlterPwd.CanFocus)
				{
					this.btnAlterPwd.Focus();
				}
				e.Handled = true;
			}
		}
		private void btnHelp_Click(object sender, EventArgs e)
		{
			Help.ShowHelp(new Control(), NoteRemote.GetNoteClientStartPath() + "\\日志管理系统帮助文件.chm", "修改密码.htm");
		}
	}
}
